<%--
  Created by IntelliJ IDEA.
  User: 王坤华
  Date: 2021/12/3
  Time: 10:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%--    <script src="js/jquery-1.8.2.min.js"></script>--%>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="bootstrap-4.6.0-dist/js/bootstrap.js"></script>
    <script src="js/fileupload.js"></script>
    <link rel="stylesheet" href="bootstrap-4.6.0-dist/css/bootstrap.css">
    <link rel="stylesheet" href="css/img.css">
    <link rel="stylesheet" href="css.css">
</head>
<body>
<div class="row">
    <div class="row-3">
        <jsp:include page="/layout/left1.jsp"></jsp:include>
    </div>
    <div class="row-9">
<form>
        id:值<input type="text" name="id" value="${id}" ><br>
    收货编号:<input type="text" name="oid" id="oid" value="${param.oid}">
    发货日期:<input type="text" name="odate"><br>
    制单人工号:<input type="text" name="zhidanrengonghao"><br>
    制单人:<input type="text" name="zhidanren"><br>
    制单时间:<input type="text" name="odatetime"><br>
    发货附件:<input type="file" name="file">
    备注:<input type="text" name="beizhu">
        <input type="button" value="修改仓库" onclick="updorder()">
<%--    <input type="button" value="修改" onclick="updwupin()">--%>
</form>
        <!-- Button trigger modal -->
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
            仓库明细添加
        </button>
        <table id="ta">
            <tr>
                <td>仓库编号</td>
                <td>名称</td>
                <td>库区</td>
                <td>库位</td>
                <td>物流编号</td>
                <td>物流名称</td>
                <td>市场价</td>
                <td>数量</td>
                <td>金额</td>
            </tr>
        </table>
        <!-- Modal -->
        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="addmi.do" method="post">
                            仓库编号:<input type="text" name="mmid" id="mmid" value="${snowid}"><br>
                            名称:<input type="text" name="mname"><br>
                            库区:<input type="text" name="kuqu"><br>
                            库位:<input type="text" name="kuwei"><br>
                            物流编号:<input type="text" name="wuliaobianhao"><br>
                            物流名称:<input type="text" name="wuliaomingcheng"><br>
                            市场价:<input type="text" name="price"><br>
                            数量:<input type="text" name="num"><br>
                            金额:<input type="text" name="zongjine"><br>
                            <input type="submit" onclick="addmi()">
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Save changes</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
</body>
<script>
    $(function () {
        let val = $("#oid").val();
        if (val.length==0){
            $.ajax({
                url:"getsnowid.do",
                type:"post",
                dataType:"text",
                success:function (obj) {
                    $("#oid").val(obj);
                    $("#mmid").val(obj);
                }
            })
        }
    })
    $.ajax({
        url:"apendList.do",
        data: {"snowid":$("#oid").val()},
        type:"post",
        dataType:"json",
        success:function (obj) {
            for (var i in obj){
                $("#ta").append("<tr>\n" +
                    "                <td>"+obj[i].mmid+"</td>\n" +
                    "                <td>"+obj[i].mname+"</td>\n" +
                    "                <td>"+obj[i].kuqu+"</td>\n" +
                    "                <td>"+obj[i].kuwei+"</td>\n" +
                    "                <td>"+obj[i].wuliaobianhao+"</td>\n" +
                    "                <td>"+obj[i].wuliaomingcheng+"</td>\n" +
                    "                <td>"+obj[i].price+"</td>\n" +
                    "                <td>"+obj[i].num+"</td>\n" +
                    "                <td>"+obj[i].zongjine+"</td>\n" +
                    "            </tr>")
            }
        }
    })
    function updorder() {
        let formData = new FormData($("form")[0]);
        $.ajax({
            url: "updorder.do",
            data:formData,
            type: "post",
            dataType: "json",
            processData:false,
            contentType:false,
            success:function (obj) {
                if (obj>0){
                    alert("修改成功")
                    location="list.do"
                }
            }
        })
    }
    $.ajax({
        url:"hui.do",
        data:{"oid":$("[name='oid']").val()},
        type:"post",
        dataType:"json",
        success:function (obj) {
            $("[name='id']").val(obj.id)
            $("[name='oid']").val(obj.oid)
            $("[name='odate']").val(obj.odate)
            $("[name='zhidanrengonghao']").val(obj.zhidanrengonghao)
            $("[name='zhidanren']").val(obj.zhidanren)
            $("[name='odatetime']").val(obj.odatetime)
            $("[name='file']").val(obj.file)
            $("[name='beizhu']").val(obj.beizhu)
        }
    })
    function updwupin() {
        location="updwupin.do"
    }
</script>
</html>
